#include "queuetask.h"

//创建一个队列
struct queuetask *create_tqueue(){
    struct queuetask *head = NULL;
    head = malloc(sizeof(struct queuetask));
    memset(head,0,sizeof(struct queuetask));

    return head;
}

//入队
void tpush(struct queuetask *que,struct task data){
    struct queuetask *node = NULL;
    struct queuetask *temp = que;

    node = malloc(sizeof(struct queuetask));
    memset(node,0,sizeof(struct queuetask));
    while(temp->next != NULL){
        temp = temp->next;
    }
    node->data = data;
    temp->next = node;
    node->next = NULL;
    temp = temp->next;
}

//找到队首元素
struct task tfront(struct queuetask *que){
    struct queuetask *temp = que->next;
    return temp->data;
}

//删除队首元素
void tpop(struct queuetask *que){
    struct queuetask *temp = que->next;
    que->next = temp->next;
    free(temp);
    temp = NULL;
}

//判断队列是否为空
int tisemptyque(struct queuetask *que){
    if(que->next == NULL){
        return 0;
    }
    return 1;
}

//求队列的大小
int tsizeofque(struct queuetask *que){
    struct queuetask *temp = que->next;
    int count = 0;
    while(temp != NULL){
        count++;
        temp = temp->next;
    }
    return count;
}